-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collision_distance_field, port to ROS 2 #65
collision_distance_field, port to ROS 2 #65
Conversation
I've left the logger at the |
See #62 (comment) |
Co-authored-by: vmayoral <[email protected]>
|
||
if(CATKIN_ENABLE_TESTING) | ||
ament_target_dependencies(${MOVEIT_LIB_NAME} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix white space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(WIN32) | ||
# TODO add windows paths | ||
else() | ||
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../planning_scene;${CMAKE_CURRENT_BINARY_DIR}/../distance_field;${CMAKE_CURRENT_BINARY_DIR}/../collision_detection;${CMAKE_CURRENT_BINARY_DIR}/../robot_state;${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../utils") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using hardcoded paths is a bad idea. Is this really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend that for every library in this package that is used else ware you set a <lib_name>_lib_dir
environment variable that can then be used by the tests
A good example is the rcl_lib_dir
I have taken the time to show how it is used below:
/home/mike/ws_ros2/src/ros2/rcl/rcl/CMakeLists.txt:
78
79: # rcl_lib_dir is passed as APPEND_LIBRARY_DIRS for each ament_add_gtest call so
80 # the librcl that they link against is on the library path.
81 # This is especially important on Windows.
82 # This is overwritten each loop, but which one it points to doesn't really matter.
83: set(rcl_lib_dir "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
84
/home/mike/ws_ros2/src/ros2/rcl/rcl/test/CMakeLists.txt:
16
17: set(extra_lib_dirs "${rcl_lib_dir}")
18
/home/mike/ws_ros2/src/ros2/rcl/rcl/test/CMakeLists.txt:
34 rcl_add_custom_gtest(test_client${target_suffix}
35 SRCS rcl/test_client.cpp
36: INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
37 ENV ${rmw_implementation_env_var}
38 APPEND_LIBRARY_DIRS ${extra_lib_dirs}
The example uses rcl_add_custom_gtest but it works just as well with ament_add_gtest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't mind I prefer to merge this. And then I will fix them all together. Because we have other merged that use this style. I can open an issue to avoid forgetting it.
#include "rclcpp/time.hpp" | ||
#include "rclcpp/utilities.hpp" | ||
|
||
static rclcpp::Logger LOGGER_COLLISION_DISTANCE_FIELD = rclcpp::get_logger("moveit").get_child("collision_distance_field"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
place inside namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...sion_distance_field/include/moveit/collision_distance_field/collision_distance_field_types.h
Show resolved
Hide resolved
@@ -102,37 +103,37 @@ class CollisionRobotDistanceField : public CollisionRobot | |||
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, | |||
const moveit::core::RobotState& state1, const moveit::core::RobotState& state2) const override | |||
{ | |||
ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); | |||
RCLCPP_ERROR(LOGGER_COLLISION_DISTANCE_FIELD, "Not implemented"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should have it's own logger. Perhaps
static rclcpp::Logger LOGGER_COLLISION_ROBOT_DISTANCE_FIELD = LOGGER_COLLISION_DISTANCE_FIELD.get_child("collision_robot_distance_field")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...sion_distance_field/include/moveit/collision_distance_field/collision_world_distance_field.h
Show resolved
Hide resolved
Please @mlautman review the changes |
|
||
namespace collision_detection | ||
{ | ||
static rclcpp::Logger LOGGER_COLLISION_DISTANCE_FIELD = rclcpp::get_logger("moveit").get_child("collision_distance_field"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROS_DEBUG_STREAM("BodyDecomposition generated " << collision_spheres_.size() << " collision spheres out of " | ||
<< shapes.size() << " shapes"); | ||
RCLCPP_DEBUG(LOGGER_COLLISION_DISTANCE_FIELD, "BodyDecomposition generated %i collision spheres out of %i shapes", | ||
collision_spheres_.size(), shapes.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrow_mark.header.frame_id = frame_id; | ||
arrow_mark.header.stamp = ros::Time::now(); | ||
arrow_mark.header.stamp = ros_clock.now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html
This needs to be RCL_ROS_TIME not RCL_SYSTEM_TIME which is the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sphere_mark.header.frame_id = frame_id; | ||
sphere_mark.header.stamp = ros::Time::now(); | ||
sphere_mark.header.stamp = ros_clock.now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html
This needs to be RCL_ROS_TIME not RCL_SYSTEM_TIME which is the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1065,7 +1075,8 @@ void CollisionRobotDistanceField::addLinkBodyDecompositions( | |||
link_body_decomposition_vector_.push_back(bd); | |||
link_body_decomposition_index_map_[link_models[i]->getName()] = link_body_decomposition_vector_.size() - 1; | |||
} | |||
ROS_DEBUG_STREAM(__FUNCTION__ << " Finished "); | |||
// RCLCPP_DEBUG_FUNCTION(LOGGER_COLLISION_ROBOT_DISTANCE_FIELD, __FUNCTION__," Finished "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ros::WallTime n = ros::WallTime::now(); | ||
|
||
// WallTime | ||
auto n = std::chrono::system_clock::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_clock.html
You can use ros::Clock with RCL_SYSTEM_TIME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROS_DEBUG_NAMED("collision_distance_field", "Modifying object %s took %lf s", obj->id_.c_str(), | ||
(ros::WallTime::now() - n).toSec()); | ||
RCLCPP_DEBUG(LOGGER_COLLISION_WORLD_DISTANCE_FIELD, "Modifying object %s took %lf s", obj->id_.c_str(), | ||
std::chrono::system_clock::now() - n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mlautman your suggestion has been addressed, you can review them |
Ping @mlautman |
friendly ping @mlautman @henningkayser @davetcoleman |
@@ -1,10 +1,5 @@ | |||
set(MOVEIT_LIB_NAME moveit_collision_distance_field) | |||
|
|||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing this. It is only a warning. Rather than remove, we should mark the overloaded functions as virtual and the overloading functions as override
if(WIN32) | ||
# TODO add windows paths | ||
else() | ||
set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_BINARY_DIR}/../planning_scene;${CMAKE_CURRENT_BINARY_DIR}/../distance_field;${CMAKE_CURRENT_BINARY_DIR}/../collision_detection;${CMAKE_CURRENT_BINARY_DIR}/../robot_state;${CMAKE_CURRENT_BINARY_DIR}/../robot_model;${CMAKE_CURRENT_BINARY_DIR}/../utils") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TODO for fixing this and assign to yourself. Otherwise, we will likely forget to get back to this
Update Dockerfile
No description provided.